<?php echo $this->element('displayHeader'); ?>
<div class="toolbar"><?php echo $this->element('toolbar', array('buttons' => array('refresh'))); ?></div>

<?php if (empty($this->data)) : // ถ้าไม่มีข้อมูล ?>
<?php echo $this->element('dataNotFound'); ?>
<? else : // ถ้ามีข้อมูล ?>
<?php $paginator->options(array('update' => 'content', 'indicator' => 'indicator')); ?>
<?php echo $this->element('dataCaptionLimit'); ?>
<?php $cur = $paginator->counter(array('format' => '%start%')); ?>

<table class="data">
    <thead>
        <tr>
            <th class="no"><?php echo $paginator->sort('No', 'User.id'); ?></th>
            <th><?php echo $paginator->sort('Username', 'User.username'); ?></th>
            <th><?php echo $paginator->sort('Name', 'User.name'); ?></th>
            <th><?php echo $paginator->sort('Surname', 'User.surname'); ?></th>
            <th><?php echo $paginator->sort('Email', 'User.email'); ?></th>
            <th><?php echo $paginator->sort('Tel.', 'User.tel'); ?></th>
            <th><?php echo $paginator->sort('Site.', 'User.site'); ?></th>
            <th width="30px">&nbsp;</th>
        </tr>
    </thead>
    <tbody>
       <?php foreach($this->data as $key => $data): ?>
        <?php
        $tableCell = array();
        $tableCell[] = $cur++;
        $tableCell[] = $data['User']['username'];
        $tableCell[] = $data['User']['name'];
        $tableCell[] = $data['User']['surname'];
        $tableCell[] = '&nbsp;' . $data['User']['email'];
        $tableCell[] = '&nbsp;' . $data['User']['tel'];
        $tableCell[] = '&nbsp;' . $data['Site']['name'];
        // edit button
        $tableCell[] =
        $ajax->link(
            $html->image('icon/edit.png', array('title' => 'edit', 'alt' => 'edit')),
                                            'view/' . $data['User']['id'],
            array('indicator' => 'indicator', 'update' => 'content'),   // เปลี่ยนหน้า
            null, false
        );
        echo $html->tableCells($tableCell, array('class' => 'odd-cell'), array('class' => 'even-cell'));
        ?>
        <?php endforeach; ?>
    </tbody>
</table>
<?php echo $this->element('paging'); ?>
<? endif; ?>